home *** CD-ROM | disk | FTP | other *** search
- /*
- $VER: RA_THE.rexx 1.0 (30.10.99) Copyright (c) Nils Görs.
-
- Thanks to William Parker for writing AWNP and for teaching me how to
- use it.
-
- This script is for editing the Tools-Menu and Hotkey functions from Workbench.
-
- The script creates an ARexx-Script that will be placed in WBStartup. You have
- to create an Icon for this script to be executed automatically.
-
- This script needs:
- - AWNPipe: ver 2.18 or newer.
- - workbench.library v44.1414 or newer.
- */
-
- Scriptname = "Sys:WBStartup/setKeyAndMenu.rexx"
- /*
- *** Please don't change anything under this line
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
- options results
-
- parse source . . called .
- PARSE ARG PubScreen
- IF PubScreen = "" THEN PubScreen = "Workbench"
-
- ADDRESS workbench
-
- ca = "THE"
-
- call _InitAll()
- call BuildGUI()
-
- Loop:
- do while ~eof(ca)
- call topipe('con')
- in= readln(ca)
-
- /*listviews need five values parsed. For string gadgets you want everything after in2 */
- parse var in in1 in2 in3 in4 in5 .
- parse var in . . infromstring
-
- if in1='iconify' then call iconify()
- if in1='gadget' then call gadget()
- if in1='menu' then call menu()
- if in1='close' then EXIT()
- end
- EXIT
-
- _InitAll:
- IF ~show('L','rexxsupport.library') THEN
- IF ~addlib('rexxsupport.library',0,-30,0) THEN
- exit(20)
-
- /* Version check */
- IF SHOWLIST('H', 'AWNPIPE') THEN res=open(ca,"awnpipe:T.H.E./-2019/xc")
- if res ~= 1 then do
- requesterdata='`requestchoice "T.H.E. Error"
- "To use this program you need AWNPipe:*n (Vers 2.18 or newer). " "OK"`'
- CALL ShellResult(requesterdata)
- exit
- end
-
- checkversion = '`version workbench.library`'
- IF WORD(ShellResult(checkversion),2) < "44.1414" THEN DO
- requesterdata='`requestchoice "T.H.E. Error"
- "To use this program you need OS 3.5*n (Vers 44.1414 or newer). " "OK"`'
- CALL ShellResult(requesterdata)
- EXIT
- END
-
-
- /* Init variables */
- TRUE = 1
- FALSE = 0
- NL = '0a'x
- TM_entries = ""
- HK_Entries = ""
- TM_STRINGNAMEVALUE = ""
- TM_STRINGTITLEVALUE = ""
- TM_STRINGSHORTCUTVALUE = ""
- TM_StringCommandValue = "rexx:"
- TM_StringArgumentValue = ""
-
- HK_StringNameValue = ""
- HK_StringHotkeyValue = ""
- HK_StringCommandValue = "rexx:"
- HK_StringArgumentValue = ""
-
- HK_counter = 0
- TM_counter = 0
-
- currentpage = 0
-
- Hotkeys = "SHIFT|LSHIFT|RSHIFT|AMIGA|LAMIGA|RAMIGA|ALT|LALT|RALT|ESC|RETURN|DEL|HELP|CTRL|CAPSLOCK|NUMERICPAD|ENTER|BACKSPACE|SPACE|COMMA|UPSTROKE"
-
- /*
- ** Set current dir
- */
-
- PARSE SOURCE . . . progdir .
-
- booll = LENGTH(progdir)
- booli= LASTPOS(":",progdir)
- boolh= LASTPOS("/",progdir)
-
-
- IF boolh > booli THEN progdir = SUBSTR(progdir,1,boolh-1)
- IF boolh == 0 THEN progdir = SUBSTR(progdir,1,booli)
-
- IF RIGHT(progdir,1) ~= ':' THEN progdir2 = progdir||'/'
- ELSE progdir2 = progdir
-
- CALL PRAGMA('D',progdir)
-
- /*
- ** Read default strings, open locale.library and catalog
- */
-
- IF ~loadrexx(progdir,'THE.strings','') THEN
- quit('Error reading file "THE.strings"!',10)
-
- IF ~SHOW('LIBRARIES','locale.library') THEN
- CALL ADDLIB('locale.library',0,-30,0)
-
- IF SHOW('LIBRARIES','locale.library') THEN DO
- id='req'pragma('id') /* get current language */
- address command 'rxset' id '`echo $language`'
- language=getclip(id)
- call setclip(id,'')
-
- IF language ~= '' THEN
- catalog = OPENCATALOG(progdir2'catalogs/'language'/THE.catalog','english',0)
-
- IF catalog = 0 THEN
- catalog = OPENCATALOG('THE.catalog','english',0)
-
- END
-
- RETURN
-
- /*******************************************************************************
- ** Load and interpret arexx script
- *******************************************************************************/
-
- loadrexx:
- PARSE ARG dir,file,store
-
- IF dir ~= '' THEN DO
- IF RIGHT(dir,1) = ':' THEN
- file = dir||file
- ELSE
- file = dir||'/'||file
- END
-
- IF ~OPEN('rexxfile',file,'R') THEN
- RETURN(FALSE)
-
- rexxtext = READCH('rexxfile',64000)
- INTERPRET rexxtext
-
- CALL CLOSE('rexxfile')
-
- IF store ~= '' THEN
- INTERPRET store '= rexxtext'
-
- DROP rexxtext
-
- RETURN(TRUE)
-
- /*******************************************************************************
- ** Text aus dem Catalog-File auslesen, falls vorhanden
- *******************************************************************************/
-
- localestring:
- PARSE ARG stringnumber
-
- IF catalog ~= 0 THEN
- RETURN(GETCATALOGSTR(catalog,stringnumber,strings.stringnumber))
- ELSE
- RETURN(strings.stringnumber)
-
- /*
- ***
- */
- iconify:
- IF in2=1 THEN call topipe('id 0 s 32') /* iconify */
- ELSE call topipe('id 0 s 64') /* uniconify */
- RETURN
-
- menu:
- IF in2 = 0 & in3 = 0 THEN DO
- requesterdata='`requestchoice "RA_THEinfo" "RA_THE.rexx 1.0 (30.10.99)*n©1999 by Nils Görs*n<nils@goers.line.org>*n*nAWNPipe © by William Parker*n<bill@amitrix.com>" "OK"`'
- CALL ShellResult(requesterdata)
-
- END
- IF in2 = 0 & in3 = 1 THEN DO
- requesterdata='`requestchoice "T.H.E." "'localestring(MSG_Request_Quit)'" "'localestring(MSG_Request_Yes)'" PUBSCREEN='pubscreen'`'
- IF ShellResult(requesterdata) = 1 THEN EXIT
- END
-
- IF in2 = 1 & in3 = 0 THEN DO
- IF currentpage = 1 THEN DO
- IF hk_counter >0 THEN DO
- call topipe('id' HK_ListviewID 'removenode')
- CALL HKClearStrings()
- hk_entries = ""
- hk_counter = 0
- END
- END
- ELSE DO
- IF tm_counter >0 THEN DO
- call topipe('id' TM_ListviewID 'removenode')
- CALL TMClearStrings()
- tm_entries = ""
- tm_counter = 0
- END
- END
- END
- IF in2 = 1 & in3 = 1 THEN DO
- IF currentpage = 1 THEN DO
- call topipe('id' HK_ListviewID 'removenode')
- hk_entries = ""
- hk_counter = 0
- call GetHotkeys()
- END
- IF currentpage = 0 THEN DO
- call topipe('id' TM_ListviewID 'removenode')
- tm_entries = ""
- tm_counter = 0
- call GetToolsMenu()
- END
- END
- RETURN
-
- Gadget:
- SELECT
- /*
- *** ListView
- */
- WHEN in2 = pageid THEN currentpage = in3
-
- WHEN in2 = TM_ListViewID THEN DO
- TM_currentnode=in5 /* remember the curently selected node for future use...*/
- CALL _UpdateTMStrings(in5)
- END
-
- WHEN in2 = HK_ListViewID THEN DO
- HK_currentnode=in5 /* remember the curently selected node for future use...*/
- IF FIND(HK_entries,HK_currentnode) = 0 THEN RETURN
-
- /* update gui for current node */
- call topipe('id 'HK_StringNameID' gt "'HK_name.in5'" ref')
- call topipe('id 'HK_StringHotKeyID' gt "'HK_Key.in5'" ref')
- call topipe('id 'HK_GetFileID' fn "'HK_command.in5'" ref')
- call topipe('id 'HK_StringArgsID' gt "'HK_Args.in5'" ref')
- IF HK_Key.in5 = "" THEN HK_HotkeyValue = ""
- ELSE HK_HotkeyValue = HK_Key.in5
-
- END
-
- /*
- *** ToolsMenu Gadgets
- */
- WHEN in2 = TM_AddID THEN DO
- Node_ID = topipe('id 'TM_ListViewID 'addnode gt "'localestring(MSG_New_Name)'|'localestring(MSG_New_Title)'||rexx:" page 'pageid)
- mt_Name = localestring(MSG_New_Name)
- mt_Title = localestring(MSG_New_Title)
- mt_ShortCut = ""
- mt_Command = "rexx:"
- mt_Args = ""
- CALL WriteTMStem()
-
- TM_CURRENTNODE=Node_ID
- call topipe2('id 'TM_ListViewID' s 'TM_CURRENTNODE)
- CALL _UpdateTMStrings(TM_CURRENTNODE)
-
- /* call topipe('id 'TM_StringNameID' s=0')*/ /* auto activation forces system-crash */
- END
-
- WHEN in2 = TM_RemoveID THEN DO
- IF TM_currentnode = "TM_CURRENTNODE" THEN RETURN
- IF topipe2('id 'TM_currentnode' address') = 0 THEN RETURN /* check if GID exists */
-
- CALL topipe('id' TM_currentnode 'removenode')
- CALL TMClearStrings()
-
- TM_counter = TM_counter - 1
- TM_entries = DELWORD(TM_entries,FIND(TM_entries,TM_currentnode),1)
- END
-
- WHEN in2 = TM_UpID THEN DO
- IF TM_CURRENTNODE = "TM_CURRENTNODE" THEN RETURN
- IF topipe2('id 'TM_currentnode' address') = 0 THEN RETURN /* check if GID exists */
-
- currentPos = FIND(TM_entries,TM_currentnode)
- prevEntry = WORD(TM_entries,currentPos-1) /* get previous entry */
- IF prevEntry = "" THEN RETURN /* Top of list */
-
- CALL swapTM
-
- TM_CURRENTNODE = prevEntry
- call topipe2('id 'TM_ListViewID' s 'TM_CURRENTNODE)
- CALL _UpdateTMStrings(TM_currentnode)
-
- END
-
- WHEN in2 = TM_DownID THEN DO
- IF TM_CURRENTNODE = "TM_CURRENTNODE" THEN RETURN
- IF topipe2('id 'TM_currentnode' address') = 0 THEN RETURN /* check if GID exists */
-
- currentPos = FIND(TM_entries,TM_currentnode)
- prevEntry = WORD(TM_entries,currentPos+1) /* get previous entry */
- IF prevEntry = "" THEN RETURN /* Top of list */
- CALL swapTM
- TM_CURRENTNODE = prevEntry
- call topipe2('id 'TM_ListViewID' s 'TM_CURRENTNODE)
- CALL _UpdateTMStrings(TM_currentnode)
- END
-
-
- /*
- *** get Stringgadget value for Tools-Menu
- */
- WHEN in2 = TM_StringNameID THEN DO
- IF TM_currentnode = "TM_CURRENTNODE" THEN TM_currentnode = -1
- TM_StringNameValue = DELWORD(in,1,2)
-
- IF TM_Args.TM_currentnode ~= "" THEN commandArgs = TM_Command.TM_currentnode TM_Args.TM_currentnode
- ELSE commandArgs = TM_Command.TM_currentnode||TM_Args.TM_currentnode
-
- IF topipe2('id 'TM_currentnode' address') ~= 0 THEN /* check if GID exists */
- call topipe('id 'TM_currentnode' gt "'TM_StringNameValue'|'TM_title.TM_currentnode'|'TM_ShortCut.TM_currentnode'|'commandArgs'"')
- TM_Name.TM_currentnode = TM_StringNameValue
- END
- WHEN in2 = TM_StringTitleID THEN DO
- IF TM_currentnode = "TM_CURRENTNODE" THEN TM_currentnode = -1
- TM_StringTitleValue = DELWORD(in,1,2)
- IF TM_Args.TM_currentnode ~= "" THEN commandArgs = TM_Command.TM_currentnode TM_Args.TM_currentnode
- ELSE commandArgs = TM_Command.TM_currentnode||TM_Args.TM_currentnode
- IF topipe2('id 'TM_currentnode' address') ~= 0 THEN /* check if GID exists */
- call topipe('id 'TM_currentnode' gt "'TM_Name.TM_currentnode'|'TM_StringTitleValue'|'TM_ShortCut.TM_currentnode'|'commandArgs'"')
- TM_Title.TM_currentnode = TM_StringTitleValue
- END
- WHEN in2 = TM_StringShortcutID THEN DO
- IF TM_currentnode = "TM_CURRENTNODE" THEN TM_currentnode = -1
- IF LENGTH(in3) > 0 THEN in3 = LEFT(in3,1)
- ELSE in3 = ""
- TM_StringShortcutValue = in3
- IF TM_Args.TM_currentnode ~= "" THEN commandArgs = TM_Command.TM_currentnode TM_Args.TM_currentnode
- ELSE commandArgs = TM_Command.TM_currentnode||TM_Args.TM_currentnode
- IF topipe2('id 'TM_currentnode' address') ~= 0 THEN /* check if GID exists */
- call topipe('id 'TM_currentnode' gt "'TM_Name.TM_currentnode'|'TM_title.TM_currentnode'|'TM_StringShortCutValue'|'commandArgs'"')
- call topipe('id 'TM_StringShortCutID 'gt "'TM_StringShortcutValue'" ref')
- TM_ShortCut.TM_currentnode = TM_StringShortCutValue
- END
- WHEN in2 = TM_GetFileID THEN DO
- IF TM_currentnode = "TM_CURRENTNODE" THEN TM_currentnode = -1
- TM_StringCommandValue = STRIP(COMPRESS(DELWORD(in,1,3),'"'))
- IF TM_Args.TM_currentnode ~= "" THEN commandArgs = TM_StringCommandValue TM_Args.TM_currentnode
- ELSE commandArgs = TM_StringCommandValue||TM_Args.TM_currentnode
- IF topipe2('id 'TM_currentnode' address') ~= 0 THEN /* check if GID exists */
- call topipe('id 'TM_currentnode' gt "'TM_Name.TM_currentnode'|'TM_title.TM_currentnode'|'TM_ShortCut.TM_currentnode'|'commandArgs'"')
- TM_Command.TM_currentnode = TM_StringCommandValue
- END
- WHEN in2 = TM_StringArgsID THEN DO
- IF TM_currentnode = "TM_CURRENTNODE" THEN TM_currentnode = -1
- TM_StringArgsValue = STRIP(COMPRESS(DELWORD(in,1,2),'"'))
- IF TM_StringArgsValue ~= "" THEN commandArgs = TM_Command.TM_currentnode TM_StringArgsValue
- ELSE commandArgs = TM_Command.TM_currentnode||TM_StringArgsValue
- IF topipe2('id 'TM_currentnode' address') ~= 0 THEN /* check if GID exists */
- call topipe('id 'TM_currentnode' gt "'TM_Name.TM_currentnode'|'TM_title.TM_currentnode'|'TM_ShortCut.TM_currentnode'|'commandArgs'"')
- TM_Args.TM_currentnode = TM_StringArgsValue
- END
-
- /*
- *** Hotkey Gadgets
- */
- WHEN in2 = HK_AddID THEN DO
- Node_ID = topipe('id 'HK_ListViewID 'addnode gt "'localestring(MSG_New_Name)'|'localestring(MSG_New_Hotkey)'|rexx:" page 'pageid)
-
- hk_Name = localestring(MSG_New_Name)
- hk_key = ""
- hk_Command = "rexx:"
- CALL WriteHKStem()
- HK_CURRENTNODE=Node_ID
- call topipe2('id 'HK_ListViewID' s 'HK_CURRENTNODE)
-
- /* update gui for current node */
- call topipe('id 'HK_StringNameID' gt "'HK_name.HK_CURRENTNODE'" ref')
- call topipe('id 'HK_StringHotKeyID' gt "'HK_Key.HK_CURRENTNODE'" ref')
- call topipe('id 'HK_GetFileID' fn "'HK_command.HK_CURRENTNODE'" ref')
- call topipe('id 'HK_StringArgsID' gt "'HK_Args.HK_CURRENTNODE'" ref')
- IF HK_Key.HK_CURRENTNODE = "" THEN HK_HotkeyValue = ""
- ELSE HK_HotkeyValue = HK_Key.HK_CURRENTNODE
-
- /* call topipe('id 'HK_StringNameID' s=0')*/ /* auto activation forces system-crash */
-
- END
-
- WHEN in2 = HK_RemoveID THEN DO
- IF HK_currentnode = "HK_CURRENTNODE" THEN RETURN
- IF topipe2('id 'HK_currentnode' address') = 0 THEN RETURN /* check if GID exists */
- CALL topipe('id' HK_currentnode 'removenode')
- CALL HKClearStrings()
-
- HK_counter = HK_counter - 1
- HK_entries = DELWORD(HK_entries,FIND(HK_entries,HK_currentnode),1)
- END
-
- /*
- *** get Stringgadget value for Hotkeys
- */
- WHEN in2 = HK_StringNameID THEN DO
- IF HK_currentnode = "HK_CURRENTNODE" THEN HK_currentnode = -1
- HK_StringNameValue = DELWORD(in,1,2)
- IF HK_Args.HK_currentnode ~= "" THEN commandArgs = HK_Command.HK_currentnode HK_Args.HK_currentnode
- ELSE commandArgs = HK_Command.HK_currentnode||HK_Args.HK_currentnode
- IF topipe2('id 'HK_currentnode' address') ~= 0 THEN /* check if GID exists */
- call topipe('id 'HK_currentnode' gt "'HK_StringNameValue'|'HK_Key.HK_currentnode'|'commandArgs'"')
- HK_Name.HK_currentnode = HK_StringNameValue
- END
-
- WHEN in2 = HK_CancelBoxID THEN DO
- IF HK_currentnode = "HK_CURRENTNODE" THEN HK_currentnode = -1
-
- call topipe('id 'HK_StringHotKeyID 'gt "" ref')
-
- IF topipe2('id 'HK_currentnode' address') ~= 0 THEN DO/* check if GID exists */
- call topipe('id 'HK_currentnode' gt "'HK_name.HK_currentnode'|""|'commandArgs'"')
- HK_Key.HK_currentnode = ""
- END
- HK_StringHotkeyValue = ""
- END
-
- WHEN in2 = HK_StringHotKeyID THEN DO
- in3 = DELWORD(in,1,2)
- IF HK_currentnode = "HK_CURRENTNODE" THEN HK_currentnode = -1
- IF in3 = "" THEN HK_StringHotkeyValue = ""
- ELSE HK_StringHotkeyValue = in3
- IF HK_Args.HK_currentnode ~= "" THEN commandArgs = HK_Command.HK_currentnode HK_Args.HK_currentnode
- ELSE commandArgs = HK_Command.HK_currentnode||HK_Args.HK_currentnode
- call topipe('id 'HK_StringHotKeyID' gt "'HK_StringHotkeyValue'" ref')
- IF topipe2('id 'HK_currentnode' address') ~= 0 THEN /* check if GID exists */
- call topipe('id 'HK_currentnode' gt "'HK_name.HK_currentnode'|'HK_StringHotkeyValue'|'commandArgs'"')
-
- HK_Key.HK_currentnode = HK_StringHotKeyValue
- END
-
- WHEN in2 = HK_chooserID THEN DO
- addHotkey = WORD(TRANSLATE(Hotkeys," ","|"),in3+1)
- IF HK_currentnode ~= "HK_CURRENTNODE" & HK_currentnode ~= -1 THEN HK_StringHotkeyValue = HK_Key.HK_currentnode
- ELSE HK_CURRENTNODE = -1
-
- IF HK_StringHotkeyValue = "" THEN HK_StringHotkeyValue = addhotkey
- ELSE HK_StringHotkeyValue = HK_StringHotkeyValue ||" "|| addHotkey
-
- IF HK_Args.HK_currentnode ~= "" THEN commandArgs = HK_Command.HK_currentnode HK_Args.HK_currentnode
- ELSE commandArgs = HK_Command.HK_currentnode||HK_Args.HK_currentnode
-
- call topipe('id 'HK_StringHotKeyID 'gt "'HK_StringHotkeyValue'"')
-
- IF topipe2('id 'HK_currentnode' address') ~= 0 THEN /* check if GID exists */
- call topipe('id 'HK_currentnode' gt "'HK_Name.HK_currentnode'|'HK_StringHotkeyValue'|'commandArgs'"')
- HK_Key.HK_currentnode = HK_StringHotKeyValue
- END
-
- WHEN in2 = HK_GetFileID THEN DO
- IF HK_currentnode = "HK_CURRENTNODE" THEN HK_currentnode = -1
- HK_StringCommandValue = STRIP(COMPRESS(DELWORD(in,1,3),'"'))
- IF HK_Args.HK_currentnode ~= "" THEN commandArgs = HK_StringCommandValue HK_Args.HK_currentnode
- ELSE commandArgs = HK_StringCommandValue||HK_Args.HK_currentnode
- IF topipe2('id 'HK_currentnode' address') ~= 0 THEN /* check if GID exists */
- call topipe('id 'HK_currentnode' gt "'HK_Name.HK_currentnode'|'HK_Key.HK_currentnode'|'commandArgs'"')
- HK_Command.HK_currentnode = HK_StringCommandValue
- END
- WHEN in2 = HK_StringArgsID THEN DO
- IF HK_currentnode = "HK_CURRENTNODE" THEN HK_currentnode = -1
- HK_StringArgsValue = STRIP(COMPRESS(DELWORD(in,1,2),'"'))
- IF HK_StringArgsValue ~= "" THEN commandArgs = HK_Command.HK_currentnode HK_StringArgsValue
- ELSE commandArgs = HK_Command.HK_currentnode||HK_StringArgsValue
- IF topipe2('id 'HK_currentnode' address') ~= 0 THEN /* check if GID exists */
- call topipe('id 'HK_currentnode' gt "'HK_Name.HK_currentnode'|'HK_Key.HK_currentnode'|'commandArgs'"')
- HK_Args.HK_currentnode = HK_StringArgsValue
- END
- /*
- *** Save|Use|Cancel gadgets
- */
- WHEN in2 = TM_SaveID | in2 = HK_SaveID THEN DO
- CALL _Save
- CALL _RemoveMenuHotkeys
- RX scriptname
- EXIT
- END
- WHEN in2 = TM_UseID | in2 = HK_UseID THEN DO
- CALL _RemoveMenuHotkeys
- Scriptname.bak = Scriptname
- Scriptname = "t:myscript"
- CALL _Save
- RX scriptname
- IF exists(scriptname) THEN DELETE scriptname
- Scriptname = Scriptname.bak
- EXIT
- END
-
- WHEN in2 = TM_CancelID | in2 = HK_CancelID THEN EXIT()
-
- OTHERWISE
- NOP
- END
- return
-
- BuildGUI:
- /* define window */
- call topipe('Title="'localestring(MSG_TitleName)'" st="Workbench Screen" Icontitle=THE iconifygadget defaultgadgets modify verticaly SpaceInner SpaceOuter topleft activate ii "'called'" pubscreen='pubscreen)
-
- /* define the menues */
- call topipe('menu gt "'localestring(MSG_MenuT_Project)'|'localestring(MSG_Menu_About)'|'localestring(MSG_Menu_Quit)'"')
- call topipe('menu gt "'localestring(MSG_MenuT_Edit)'|'localestring(MSG_Menu_Remove)'|'localestring(MSG_Menu_LastSaved)'"')
-
- /* define the gadgets*/
- pageid = topipe('clicktab ctl "'localestring(MSG_MAIN_ToolsMenu)'|'localestring(MSG_MAIN_HotkeyMenu)'"')
-
- call topipe('layout b=0 v page' pageid)
- call topipe('layout si so gt='localestring(MSG_TM_ToolsMenu))
- TM_ListViewID = topipe('listbrowser lbl="'localestring(MSG_TM_LV_Title)'" arrows vert hori minh=120 minw=300 showtitles')
- call topipe(le)
-
- call topipe('layout hori so b=0 weih=0')
- TM_AddID = topipe('button gt "'localestring(MSG_Button_Add)'"')
- call topipe('space')
- TM_RemoveID = topipe('button gt "'localestring(MSG_Button_Remove)'"')
- call topipe('space')
- TM_UpID = topipe('button gt "'localestring(MSG_Button_Up)'"')
- call topipe('space')
- TM_DownID = topipe('button gt "'localestring(MSG_Button_Down)'"')
- call topipe(le)
-
- call topipe('layout v si so weih 0')
- call topipe('label gt "'localestring(MSG_String_Name)'" ua')
- TM_StringNameID = topipe('string chl lj tc')
- call topipe('label gt "'localestring(MSG_String_Title)'" ua')
- TM_StringTitleID = topipe('string chl lj tc')
- call topipe('label gt "'localestring(MSG_String_ShortCut)'" ua')
- TM_StringShortCutID = topipe('string chl lj tc maxchars=3')
- call topipe('label gt "'localestring(MSG_String_Command)'" ua')
- TM_GetFileID = topipe('getfile chl fn "rexx:"')
- call topipe('label gt "'localestring(MSG_String_Argument)'" ua')
- TM_StringArgsID = topipe('string chl lj tc')
- call topipe(le)
-
- call topipe('layout b=0 v si so weih 0')
- call topipe('button b=7 minh 2')
- call topipe('layout b=0 h si so weih 0')
- TM_SaveID = topipe('button weiw 0 gt "'localestring(MSG_Button_Save)'"')
- call topipe('space')
- TM_UseID = topipe('button weiw 0 gt "'localestring(MSG_Button_Use)'"')
- call topipe('space')
- TM_CancelID = topipe('button weiw 0 gt "'localestring(MSG_Button_Cancel)'"')
- call topipe(le)
- call topipe(le)
- call topipe(le)
-
- call topipe('layout b 0 v page' pageid)
- call topipe('layout si so gt="'localestring(MSG_HK_Hotkey)'"')
- HK_ListViewID = topipe('listbrowser lbl="'localestring(MSG_HK_LV_Title)'" arrows vert hori minh=120 minw=300 showtitles')
- call topipe(le)
-
- call topipe('layout hori so b=0 weih=0')
- HK_AddID = topipe('button gt "'localestring(MSG_Button_Add)'"')
- call topipe('space')
- HK_RemoveID = topipe('button gt "'localestring(MSG_Button_Remove)'"')
- call topipe(le)
-
- call topipe('layout v si so weih 0')
- call topipe('label gt "'localestring(MSG_String_Name)'" ua')
- HK_StringNameID = topipe('string chl lj tc')
- call topipe('label gt "'localestring(MSG_String_HotKey)'" ua')
- call topipe('layout chl bj b=0')
-
- HK_StringHotKeyID = topipe('string chl lj tc')
- HK_CancelBoxID = topipe('button autobutton=4 weiw=0')
- HK_ChooserID = topipe('chooser chl lj maxn=21 cl='hotkeys)
- call topipe('le')
- call topipe('label gt "'localestring(MSG_String_Command)'" ua')
- HK_GetFileID = topipe('getfile chl fn "rexx:"')
- call topipe('label gt "'localestring(MSG_String_Argument)'" ua')
- HK_StringArgsID = topipe('string chl lj tc')
- call topipe(le)
-
- call topipe('layout b=0 v si so weih 0')
- call topipe('button b=7 minh 2')
- call topipe('layout b=0 h si so weih 0')
- HK_SaveID = topipe('button weiw 0 gt "'localestring(MSG_Button_Save)'"')
- call topipe('space')
- HK_UseID = topipe('button weiw 0 gt "'localestring(MSG_Button_Use)'"')
- call topipe('space')
- HK_CancelID = topipe('button weiw 0 gt "'localestring(MSG_Button_Cancel)'"')
- call topipe(le)
- call topipe(le)
-
- /*open the GUI window*/
- call topipe("open")
-
- /* now create the listview entries */
- call GetToolsMenu()
- call GetHotkeys()
- RETURN
-
-
- topipe:
- /* this routine does error checking on lines written to pipe.*/
- /*get line to output*/
- parse arg out
-
- /* write to the pipe*/
- call writeln(ca,out)
-
- /*get responce and parse it.*/
- in=readln(ca)
- parse var in res1 res2 .
-
- /* if all is ok return the second part of the responce (usualy the GID)*/
- if res1='ok' then return(res2)
-
- /* something went wrong, we notify the user then exit */
- /*show problem line and responce (reponce may be just a blank line)*/
- say 'error from: 'out
- say ' responce: ' in
- exit
-
- topipe2:
- /* this routine does error checking on lines written to pipe.*/
-
- /*get line to output*/
- parse arg out
-
- /* write to the pipe*/
- call writeln(ca,out)
-
- /*get responce and parse it.*/
- in=readln(ca)
- parse var in res1 res2 .
-
- return(res1)
-
- /*
- */
- GetToolsMenu:
- GETATTR MENUCOMMANDS.COUNT
- ToolsMenu.0 = result
-
- call topipe('id 'TM_ListViewID 'list 0')
-
- DO i = 0 to ToolsMenu.0 -1
- GETATTR MENUCOMMANDS.i.NAME
- mt_name = result
- GETATTR MENUCOMMANDS.i.TITLE
- mt_title = result
- GETATTR MENUCOMMANDS.i.SHORTCUT
- mt_shortcut = result
- GETATTR MENUCOMMANDS.i.COMMAND
- mt_command = result
- /* get the GID of the node, save the contents of the node for further reference. */
- Node_ID = topipe('id 'TM_ListViewID 'addnode gt "'mt_name'|'mt_title'|'mt_shortcut'|'mt_command'" page 'pageid)
-
- CALL WriteTMStem()
- END
- call topipe('id 'TM_ListViewID 'list 1 page' pageid)
- RETURN
-
- GetHotkeys:
- GETATTR KEYCOMMANDS.COUNT
- Hotkeys.0 = result
- call topipe('id 'HK_ListViewID 'list 0')
- DO i = 0 to Hotkeys.0 -1
- GETATTR KEYCOMMANDS.i.NAME
- hk_name = result
- GETATTR KEYCOMMANDS.i.KEY
- hk_key = result
- GETATTR KEYCOMMANDS.i.COMMAND
- hk_command = result
-
- /* get the GID of the node, save the contents of the node for further reference. */
- Node_ID = topipe('id 'HK_ListViewID 'addnode gt "'hk_name'|'hk_key'|'hk_command'" page 'pageid)
- call writeHKStem()
- END
- call topipe('id 'HK_ListViewID 'list 1 page' pageid)
- RETURN
-
- WriteTMStem:
- TM_name.Node_ID=mt_name
- TM_title.Node_ID=mt_title
- TM_Shortcut.Node_ID=mt_shortcut
- call parseTMArgs() /* write command and args */
-
- TM_counter = TM_counter + 1
- TM_Entries = TM_Entries Node_ID /* add GID to TM_entries */
- RETURN
-
- TMClearStrings:
- CALL topipe('id 'TM_StringNameID 'gt ""')
- CALL topipe('id 'TM_StringTitleID 'gt ""')
- CALL topipe('id 'TM_StringShortCutID 'gt ""')
- CALL topipe('id 'TM_GetFileID 'fn "rexx:"')
- CALL topipe('id 'TM_StringArgsID 'gt ""')
- TM_StringNameValue = ""
- TM_StringTitleValue = ""
- TM_StringShortcutValue = ""
- TM_StringCommandValue = "rexx:"
- TM_StringArgsValue = ""
- RETURN
-
- WriteHKStem:
- HK_Name.Node_ID = HK_name
- HK_Key.Node_ID = HK_Key
- call parseHKArgs() /* write command and args */
-
- HK_counter = HK_counter + 1
- HK_Entries = HK_Entries Node_ID /* add GID to HK_entries */
- RETURN
-
- HKClearStrings:
- CALL topipe('id 'HK_StringNameID 'gt ""')
- CALL topipe('id 'HK_StringHotKeyID 'gt ""')
- CALL topipe('id 'HK_GetFileID 'fn "rexx:"')
- CALL topipe('id 'HK_StringArgsID 'gt ""')
- HK_StringNameValue = ""
- HK_StringHotKeyValue = ""
- HK_StringCommandValue = "rexx:"
- HK_StringArgsValue = ""
-
- RETURN
-
- _Save:
- IF TM_counter = 0 & HK_counter = 0 THEN RETURN
- CALL OPEN(file,scriptname,write)
- CALL WRITELN(file,"/*"localestring(MSG_Created)" T.H.E.*/"||NL||"ADDRESS WORKBENCH")
-
- IF HK_counter >0 THEN DO
- DO i = 1 to WORDS(HK_entries)
- val = WORD(HK_entries,i)
- IF HK_Args.val ~= "" THEN commandArgs = HK_Command.val HK_Args.val
- ELSE commandArgs = HK_Command.val||HK_Args.val
- CALL WRITELN(file,KEYBOARD ADD NAME '''"'||HK_Name.val||'"''' KEY '''"'||HK_Key.val||'"''' CMD '"'||commandArgs||'"')
- END
- END
-
- IF TM_counter >0 THEN DO
- CALL WRITELN(file,"")
- DO i = 1 to WORDS(tm_entries)
- val = WORD(tm_entries,i)
- IF TM_Args.val ~= "" THEN commandArgs = TM_Command.val TM_Args.val
- ELSE commandArgs = TM_Command.val||TM_Args.val
-
- IF TM_Shortcut.val = "" THEN CALL WRITELN(file,MENU ADD NAME '''"'||TM_name.val||'"''' TITLE '''"'||TM_title.val||'"''' CMD '"'||commandArgs||'"')
- ELSE CALL WRITELN(file,MENU ADD NAME '''"'||TM_name.val||'"''' TITLE '''"'||TM_title.val||'"''' SHORTCUT '"'||TM_Shortcut.val||'"' CMD '"'||commandArgs||'"')
- END
- END
- CALL CLOSE(file)
- RETURN
-
- _RemoveMenuHotkeys:
- GETATTR KEYCOMMANDS.COUNT
- clearkey = result
- DO i = clearKey - 1 to 0 BY - 1
- GETATTR KEYCOMMANDS.i.NAME
- name1 = result
- KEYBOARD NAME name1 REMOVE
- END
-
- GETATTR MENUCOMMANDS.COUNT
- clearMenu = result
- DO i = clearMenu - 1 to 0 BY - 1
- GETATTR MENUCOMMANDS.i.NAME
- name1 = result
- MENU NAME name1 REMOVE
- END
- RETURN
-
- _UpdateTMStrings:
- PARSE ARG val
- /* update gui for current node */
- IF FIND(tm_entries,TM_currentnode) = 0 THEN RETURN
- call topipe('id 'TM_StringNameID' gt "'TM_name.val'" ref')
- call topipe('id 'TM_StringTitleID' gt "'TM_title.val'" ref')
- call topipe('id 'TM_StringShortcutID' gt "'TM_shortcut.val'" ref')
- call topipe('id 'TM_GetFileID' fn "'TM_command.val'" ref')
- call topipe('id 'TM_StringArgsID' gt "'TM_Args.val'" ref')
- RETURN
-
- SwapTM:
- TM_name.bak1 = TM_Name.prevEntry
- TM_name.bak2 = TM_Name.TM_currentnode
- TM_Title.bak1 = TM_Title.prevEntry
- TM_Title.bak2 = TM_Title.TM_currentnode
- TM_ShortCut.bak1 = TM_ShortCut.prevEntry
- TM_ShortCut.bak2 = TM_ShortCut.TM_currentnode
- TM_Command.bak1 = TM_Command.prevEntry
- TM_Command.bak2 = TM_Command.TM_currentnode
- TM_Args.bak1 = TM_Args.prevEntry
- TM_Args.bak2 = TM_Args.TM_currentnode
-
- TM_Name.prevEntry = TM_name.bak2
- TM_Name.TM_currentnode = TM_name.bak1
- TM_Title.prevEntry = TM_Title.bak2
- TM_Title.TM_currentnode = TM_Title.bak1
- TM_ShortCut.prevEntry = TM_ShortCut.bak2
- TM_ShortCut.TM_currentnode = TM_ShortCut.bak1
- TM_Command.prevEntry = TM_Command.bak2
- TM_Command.TM_currentnode = TM_Command.bak1
- TM_Args.prevEntry = TM_Args.bak2
- TM_Args.TM_currentnode = TM_Args.bak1
-
- call topipe2('id 'TM_ListViewID' list 0')
- IF TM_Args.TM_currentnode ~= "" THEN commandArgs = TM_Command.TM_currentnode TM_Args.TM_currentnode
- ELSE commandArgs = TM_Command.TM_currentnode||TM_Args.TM_currentnode
- call topipe('id 'TM_currentnode' gt "'TM_Name.TM_currentnode'|'TM_title.TM_currentnode'|'TM_ShortCut.TM_currentnode'|'commandArgs'"')
-
- IF TM_Args.prevEntry ~= "" THEN commandArgs = TM_Command.prevEntry TM_Args.prevEntry
- ELSE commandArgs = TM_Command.prevEntry||TM_Args.prevEntry
- call topipe('id 'prevEntry' gt "'TM_Name.prevEntry'|'TM_title.prevEntry'|'TM_ShortCut.prevEntry'|'commandArgs'"')
- call topipe2('id 'TM_ListViewID' list 1 page' pageid)
- RETURN
-
- ShellResult:
- PARSE ARG ShellCmd
- cmdid='req'pragma('id')
- address command 'rxset' cmdid Shellcmd
- from_Shell=getclip(cmdid)
- call setclip(cmdid,'')
- RETURN(from_Shell)
-
- parseTMArgs:
- IF WORDS(mt_command) >1 THEN DO /* more than one word? */
- firstchar= INDEX(mt_command,":")
- firstArg = INDEX(mt_command," ",firstchar)
- IF firstArg = 0 THEN firstArg = 1
- TM_command.Node_ID= SUBSTR(mt_command,1,firstArg-1)
- TM_Args.Node_ID = RIGHT(mt_command,LENGTH(mt_command)-firstArg)
- END
- ELSE DO
- TM_command.Node_ID=mt_command
- TM_Args.Node_ID = ""
- END
- RETURN
-
- parseHKArgs:
- IF WORDS(hk_command) >1 THEN DO /* more than one word? */
- firstchar= INDEX(hk_command,":")
- firstArg = INDEX(hk_command," ",firstchar)
- HK_command.Node_ID= SUBSTR(hk_command,1,firstArg-1)
- HK_Args.Node_ID = RIGHT(hk_command,LENGTH(hk_command)-firstArg)
- END
- ELSE DO
- HK_command.Node_ID=hk_command
- HK_Args.Node_ID = ""
- END
- RETURN
-